package com.example;

/**
 * @desc:
 * @author: Shoko
 * @date: 2025/5/25
 */
public class MonitorSystemTest {
    public static void main(String[] args) {
        // 创建传感器
        Sensor sensor = new Sensor();

        // 创建响应设备
        ResponseDevice warningLight = new WarningLight();
        ResponseDevice alarm = new Alarm();
        ResponseDevice escapeDoor = new EscapeDoor();

        // 注册响应设备
        sensor.attach(warningLight);
        sensor.attach(alarm);
        sensor.attach(escapeDoor);

        System.out.println("=== 测试1: 温度25℃ ===");
        TempEvent normalTemp = new TempEvent("正常", 25);
        sensor.notify(normalTemp);

        System.out.println("\n=== 测试2: 温度32℃ ===");
        TempEvent highTemp = new TempEvent("过高", 32);
        sensor.notify(highTemp);

        System.out.println("\n=== 测试3: 温度37℃ ===");
        TempEvent dangerTemp = new TempEvent("危险", 37);
        sensor.notify(dangerTemp);

        System.out.println("\n=== 测试4: 温度42℃ ===");
        TempEvent extremeTemp = new TempEvent("极度危险", 42);
        sensor.notify(extremeTemp);
    }
}
